package com.xbb.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import com.xbb.entity.Statistics;
import com.xbb.mapper.CommodityMapper;
import com.xbb.entity.Commodity;
import com.xbb.service.CommodityService;
import org.springframework.stereotype.Service;

@Service
public class CommodityServiceImpl implements CommodityService {

    @Resource
    private CommodityMapper commodityMapper;

    // 删除数据
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return commodityMapper.deleteByPrimaryKey(id);
    }

    // 插入数据
    @Override
    public int insert(Commodity commodity) {
        return commodityMapper.insert(commodity);
    }

    // 插入数据
    @Override
    public int insertSelective(Commodity commodity) {
        return commodityMapper.insertSelective(commodity);
    }

    // 根据ID查询单个数据
    @Override
    public Commodity selectByPrimaryKey(Integer id) {
        return commodityMapper.selectByPrimaryKey(id);
    }

    // 修改数据
    @Override
    public int updateByPrimaryKeySelective(Commodity commodity) {
        return commodityMapper.updateByPrimaryKeySelective(commodity);
    }

    // 修改数据
    @Override
    public int updateByPrimaryKey(Commodity commodity) {
        return commodityMapper.updateByPrimaryKey(commodity);
    }

    // 根据条件查询分页数据
    @Override
    public List<Commodity> selectListByPaging(Integer page, Integer limit,String name, Integer categoryId, String number, Boolean status, Integer userId) {
        return commodityMapper.selectListByPaging(
            (page - 1) * limit,
            limit,
            name,
            categoryId,
            number,
            status,
            userId
        );
    }

    // 根据条件查询数据条数
    @Override
    public int selectCountByPaging(String name, Integer categoryId, String number, Boolean status, Integer userId) {
        return commodityMapper.selectCountByPaging(
            name,
            categoryId,
            number,
            status,
            userId
        );
    }

    // 查询全部数据
    @Override
    public List<Commodity> selectAll() {
        return commodityMapper.selectAll();
    }

    // 根据条件查询列表数据
    @Override
    public List<Commodity> selectList(Commodity commodity) {
        return commodityMapper.selectList(commodity);
    }

    // 根据字段、排序方式、limit条 查询列表数据
    @Override
    public List<Commodity> selectListByLimit(String field, String sort, Integer limit) {
        return commodityMapper.selectListByLimit(field, sort, limit);
    }

    // 根据字段查询列表数据
    @Override
    public List<Commodity> selectListByField(String field, Object value) {
        return commodityMapper.selectListByField(field, value);
    }

    // 根据条件查询单个数据
    @Override
    public Commodity selectOne(Commodity commodity) {
        return commodityMapper.selectOne(commodity);
    }

    // 根据ID查询详情数据
    @Override
    public Commodity selectOneByDetails(Integer id) {
        return commodityMapper.selectOneByDetails(id);
    }

    // 查询全部条数
    @Override
    public int selectAllCount() {
        return commodityMapper.selectAllCount();
    }

    // 根据条件查询数据条数
    @Override
    public int selectCount(Commodity commodity) {
        return commodityMapper.selectCount(commodity);
    }

    // 根据条件修改全部数据
    @Override
    public int updateAll(Commodity commodity) {
        return commodityMapper.updateAll(commodity);
    }

    @Override
    public List<Statistics> selectStatisticsByCategory() {
        return commodityMapper.selectStatisticsByCategory();
    }
}
